#ifndef __LOG_H__
#define __LOG_H__

#define DEBUG_EN (1u)
 
#if (DEBUG_EN)
	
	#include <stdio.h>
	#include <stdint.h>

	#define DEBUG_MAX_SIZE 512
	#define PLATFORM_PUTBUF(buf,len) printf("%s\n",buf)
	
	extern char szBuf[DEBUG_MAX_SIZE];
	 
	#define DEBUG_INFO( format, ... ) do{\
		uint16_t unLen = 0;\
		unLen += snprintf(szBuf+unLen,DEBUG_MAX_SIZE, "[INFO][%s][@%s][#%d]:",__FILE__,__FUNCTION__,__LINE__);\
		unLen += snprintf(szBuf+unLen,DEBUG_MAX_SIZE-unLen, format, ## __VA_ARGS__ );\
		PLATFORM_PUTBUF(szBuf,unLen);\
	}while(0)
	 
	#define DEBUG_WARN( format, ... ) do{\
		uint16_t unLen = 0;\
		unLen += snprintf(szBuf+unLen,DEBUG_MAX_SIZE, "[WARN][%s][@%s][#%d]:",__FILE__,__FUNCTION__,__LINE__);\
		unLen += snprintf(szBuf+unLen,DEBUG_MAX_SIZE-unLen, format, ## __VA_ARGS__ );\
		PLATFORM_PUTBUF(szBuf,unLen);\
	}while(0)
	 
	#define DEBUG_ERR( format, ... ) do{\
		uint16_t unLen = 0;\
		unLen += snprintf(szBuf+unLen,DEBUG_MAX_SIZE, "[ERR][%s][@%s][#%d]:",__FILE__,__FUNCTION__,__LINE__);\
		unLen += snprintf(szBuf+unLen,DEBUG_MAX_SIZE-unLen, format, ## __VA_ARGS__ );\
		PLATFORM_PUTBUF(szBuf,unLen);\
	}while(0)
 
#elif 
 
	#define DEBUG_INFO(...)
	#define DEBUG_WARN(...)
	#define DEBUG_ERR(...)
 
#endif

void platform_send_buf(char*buf,uint16_t len);

#endif
